<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Color
 *
 * @author QuangKhoi
 */
class Color {

    //put your code here
    public $numberOfColors;

    public static function getFromImage($url) {
        include_once("Libs/colors/colors.inc.php");
        $ex = new GetMostCommonColors();
        $ex->image = $url;
        $colors = $ex->Get_Color();
        $colors_key = array_keys($colors);
        return $colors_key;
    }
    
    public static function getColorBar($url) {
        $colors = Color::getFromImage($url);
        $result = "";
        for($i = 0; $i < 10; $i++){
            if($i == 0)
                $result = $result."<li class=\"color current\"><a style=\"background-color: #$colors[$i]\" title=\"#$colors[$i]\">#$colors[$i]</a></li>";
            $result = $result."<li class=\"color\"><a style=\"background-color: #$colors[$i]\" title=\"#$colors[$i]\">#$colors[$i]</a></li>";
        }
        return $result;
    }
    
    public static function getColorBarNotDefault($url){
        $colors = Color::getFromImage($url);
        $result = "";
        for($i = 0; $i < 8; $i++){
            $result = $result."<li class=\"color\"><a style=\"background-color: #$colors[$i]\" title=\"#$colors[$i]\">#$colors[$i]</a></li>";
        }
        return $result;
    }
}

?>
